<!-- 申请弹窗 -->
<template>
  <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
      <div class="modal-content wrapper">
        <div class="close-wrapper">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        </div>
        <div class="title" id="myModalLabel">请留下您的联系方式和商户信息</div>
        <div class="modal-body container-fuild">
          <div class="row">
            <div class="col-lg-8 col-lg-offset-2">
              <label>联系人：</label>
              <input v-model="formData.name" type="text" class="form-control">
              <label>联系方式：</label>
              <input v-model="formData.tel" type="text" class="form-control">
              <label>商户类型：</label>
              <input v-model="formData.kind" type="text" placeholder="例如：餐饮、服装、娱乐等" class="form-control">
              <button @click="submit" type="button" class="btn btn-block btn-primary">确认</button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  apply
} from '../../../api/api'
export default {
  name: 'appliDialog',
  components: {},
  data () {
    return {
      formData: {
        name: '',
        tel: '',
        kind: ''
      }
    }
  },
  methods:{
    submit() {
      const formData = this.formData
      if (!formData.name.trim()) {
        alert('请输入联系人')
        return
      }
      if (!formData.tel.trim()) {
        alert('请输入联系方式')
        return
      }
      if (!formData.kind.trim()) {
        alert('请输入商户类型')
        return
      }
      
      apply(this.formData).then(res => {
        console.log(res) 
        if (res.status === 200) {
          alert('提交成功')
          $('#myModal').modal('hide')
          this.formData = {
            name: '',
            tel: '',
            kind: ''
          }
        }
      })
    }
  },
}
</script>

<style lang="less" scoped>
.close-wrapper{
  display: block;
  background: #0196FE;
  opacity: 0.4;
  width: 26px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  position: absolute;
  border-radius: 50%;
  right: 20px;
  top: 28px;
  .close{
    color: #ffffff;
    font-size: 20px;
    opacity: 1;
    margin-top: 3px;
    margin-right: 7px;
  }
}

.wrapper{
  padding: 30px 0;
  position: relative;
}
.title{
  color: #111111;
  font-size: 20px;
  text-align: center;
}
label{
  color: #999999;
}
input + label{
  margin-top: 15px;
}
.btn{
  margin-top: 20px;
  border-radius: 30px;
  background: #0196FE;
  border-color: #0196FE;
  padding: 10px 0;
}
</style>
